package willevaluate.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.xuegengwang.xuegengwang.R;

import java.util.List;

import utils.UnitUtils;
import willevaluate.bean.ExpertEvaluateQuestionListBean;

/**
 * Created by Administrator on 2017/5/26.
 */

public class ExpertEvaluateStatusAdapter extends BaseAdapter {
    private Context context;
    private List<ExpertEvaluateQuestionListBean.ListBean> list;

    public ExpertEvaluateStatusAdapter(Context context, List<ExpertEvaluateQuestionListBean.ListBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyHolder myHolder;
        if(convertView == null){
            myHolder = new MyHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.expert_evaluate_status_item,null);
            myHolder.expert_evaluate_status_item_question = (TextView) convertView.findViewById(R.id.expert_evaluate_status_item_question);
            myHolder.expert_evaluate_status_item_time = (TextView) convertView.findViewById(R.id.expert_evaluate_status_item_time);
            myHolder.expert_evaluate_status_item_status = (ImageView) convertView.findViewById(R.id.expert_evaluate_status_item_status);
            convertView.setTag(myHolder);
        }else{
            myHolder = (MyHolder) convertView.getTag();
        }
        myHolder.expert_evaluate_status_item_question.setText(list.get(position).getQuestion());
        myHolder.expert_evaluate_status_item_time.setText(list.get(position).getQuestion_time());
        if("0".equals(list.get(position).getStatus())){
            myHolder.expert_evaluate_status_item_status.setImageResource(R.mipmap.unanswer_ima);
        }else{
            myHolder.expert_evaluate_status_item_status.setImageResource(R.mipmap.expert_evaluate_answered_ima);
        }

        return convertView;
    }

    class MyHolder{
        TextView expert_evaluate_status_item_question;
        TextView expert_evaluate_status_item_time;
        ImageView expert_evaluate_status_item_status;
    }
}
